<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8">
	<title>Barcode Example</title>
	<script type="text/javascript" >
// 扩展API加载完毕后调用onPlusReady回调函数 
document.addEventListener( "plusready", onPlusReady, false );
// 扩展API加载完毕，现在可以正常调用扩展API
function onPlusReady() {
	var e = document.getElementById("scan");
	e.removeAttribute( "disabled" );
}
var scan = null;
function onmarked( type, result ) {
	var text = '未知: ';
	switch(type){
		case plus.barcode.QR:
		text = 'QR: ';
		break;
		case plus.barcode.EAN13:
		text = 'EAN13: ';
		break;
		case plus.barcode.EAN8:
		text = 'EAN8: ';
		break;
	}
	alert( text+result );
}
function startRecognize() {
	scan = new plus.barcode.Barcode('bcid');
	scan.onmarked = onmarked; 
}
function startScan() {
	scan.start();
}
function cancelScan() {
	scan.cancel();
}
function setFlash() {
	scan.setFlash();
}
	</script>
	<style type="text/css">
*{
	-webkit-user-select: none;
}
html,body{
	margin: 0px;
	padding: 0px;
	height: 100%;
}
#bcid {
	background:#0F0;
	height:480px;
	width:360px;
}
	</style>
	</head>
	<body >
		<input type='button' onclick='startRecognize()' value='创建扫码控件' />
		<input type='button' onclick='startScan()' value='开始扫码' />
		<input type='button' onclick='cancelScan()' value='取消扫码' />
		<input type='button' onclick='setFlash()' value='开启闪光灯' />
		<div id="bcid"></div>
		<input type='text' id='text'/>
	</body>
</html>